﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GrewalCRM.BLL;
using GrewalCRM.Entities;
using System.Collections;

public partial class Admin_Admin : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!Page.IsPostBack)
      {
 
      }
    }
    protected void ddlAction_SelectedIndexChanged(object sender, EventArgs e)
    {
      string adminAction = ddlAction.SelectedItem.Text;
      switch (adminAction)
      {
        case "Add AC Brand":
          mvActions.SetActiveView(vwAddACBrand);
          break;
        case "Add Installer":
          mvActions.SetActiveView(vwInstaller);
          break;
        case "Add Dealer":
          mvActions.SetActiveView(vwDealer);
          break;
      }
    }
    protected void odsAcBrand_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {      
      IDictionary paramsFromPage = e.InputParameters;

      ACBrands acBrand = paramsFromPage["Entity"] as ACBrands;
      acBrand.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearACBrandsCache();
    }
    protected void odsAcBrand_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      ACBrands acBrand = paramsFromPage["Entity"] as ACBrands;
      acBrand.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearACBrandsCache();
    }
    protected void odsAcBrand_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      ACBrands acBrand = paramsFromPage["Entity"] as ACBrands;
      acBrand.LastModifiedUser = MasterCRM.SessionUser;
      acBrand.IsActive = false;
      acBrand.IsMarkedDeleted = true;
      MasterCRM.ClearACBrandsCache();
    }

    protected void odsInstaller_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;

      InstallersMaster installer = paramsFromPage["Entity"] as InstallersMaster;
      installer.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearInstallersCache();
    }
    protected void odsInstaller_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      InstallersMaster installer = paramsFromPage["Entity"] as InstallersMaster;
      installer.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearInstallersCache();
    }
    protected void odsInstaller_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      InstallersMaster installer = paramsFromPage["Entity"] as InstallersMaster;
      installer.LastModifiedUser = MasterCRM.SessionUser;
      installer.IsActive = false;
      installer.IsMarkedDeleted = true;
      MasterCRM.ClearInstallersCache();
    }

    protected void odsDealer_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;

      DealersMaster dealer = paramsFromPage["Entity"] as DealersMaster;
      dealer.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearDealerCache();
    }
    protected void odsDealer_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      DealersMaster dealer = paramsFromPage["Entity"] as DealersMaster;
      dealer.LastModifiedUser = MasterCRM.SessionUser;
      MasterCRM.ClearDealerCache();
    }
    protected void odsDealer_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
    {
      IDictionary paramsFromPage = e.InputParameters;
      DealersMaster dealer = paramsFromPage["Entity"] as DealersMaster;
      dealer.LastModifiedUser = MasterCRM.SessionUser;
      dealer.IsActive = false;
      dealer.IsMarkedDeleted = true;
      MasterCRM.ClearDealerCache();
    }

    private ImasterCRM MasterCRM
    {
      get { return this.Page.Master as ImasterCRM; }
    }
}